package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringConstructOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringInstallOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringConstructOrderBean;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringInstallationOrderBean;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringConstructOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringInstallOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringConstructOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringInstallOrderDetailModel;

/**
 * Created by tony on 2018/4/5.
 */

public class EngineeringConstructOrderDetailPresenter {
    private IEngineeringConstructOrderDetailView view;
    private IEngineeringConstructOrderDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringConstructOrderDetailPresenter(IEngineeringConstructOrderDetailView view) {
        this.view = view;
        this.model = new EngineeringConstructOrderDetailModel();
    }

    public void getEngineeringConstructOrderDetail() {


        model.getEngineeringConstructOrderDetail(view.getOrderId(), new EngineeringConstructOrderDetailModel.OnEngineeringConstructOrderDetailListener() {
            @Override
            public void successed(final EngineeringConstructOrderBean constructOrderBean) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringConstructOrderDetailSuccessed(constructOrderBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringConstructOrderDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
